<template>
    <div class="table">
        <div class="crumbs">
            <el-breadcrumb separator="/">
                <el-breadcrumb-item> 黑名单</el-breadcrumb-item>
            </el-breadcrumb>
        </div>
        
         <el-table :data="newsCenter" border style="width: 100%" ref="multipleTable">
        
            <el-table-column prop="a_title" label="头像"  width="120">
            <template scope="scope">
              <img :src="scope.row.u_avatar" width="100%"/>
            </template>
            </el-table-column>
            <el-table-column prop="a_type_name" label="昵称"  width="120">
            </el-table-column>
             <el-table-column prop="a_type_name" label="留言内容">
            </el-table-column>
                  <el-table-column prop="a_publish_time"  sortable  label="发布时间"  :formatter="time_filter" width="150">
            </el-table-column>
     
        </el-table>
        <div class="pagination">
            <el-pagination
                    @current-change ="handleCurrentChange"
                    layout="prev, pager, next"
                    :total="all_page">
            </el-pagination>
        </div>
    </div>
</template>

<script>
import * as rpConfig from "../../../rpConfig/constant";
import { HttpReq } from "../../service/server";
var Server = new HttpReq();
export default {
  data() {
    return {
      url: "./static/vuetable.json",
      newsCenter: [],
      intime: "",
      outtime:"",
      addActivity: true
    };
  },
  created() {
    this.getData();
    this.getType();
  },
  computed: {},
  methods: {
    handleCurrentChange(val) {
      this.cur_page = val;
      this.getData();
    },
    closeEdit() {
      this.addActivity = false;
    },
    getData() {
      let self = this;
      Server._POST(
        rpConfig.API_URI + "/newscenter.Index/getNewsByCon",
        {
          page: self.cur_page,
          a_type_id: self.select_cate,
          keyword: self.select_word
        },
        function(res) {
          self.newsCenter = res.data.data;
          self.all_page = Math.ceil(res.data.num / res.data.pagesize) * 10;
        }
      );
    },
    getType() {
      let self = this;
      Server._POST(
        rpConfig.API_URI + "/newscenter.Index/getNewsType",
        {},
        function(response) {
          self.typeCenter = response.data;
        }
      );
    },
    time_filter(row) {
      return row.a_publish_time.substring(0, 16);
    },
    publish_formatter(row) {
      return row.a_state == 1 ? "上线内容" : "草稿";
    },
    filterTag(value, row) {
      return row.tag === value;
    },
    handleEdit(row) {
      this.$router.push("/newsedit/" + row.a_id);
      //this.$message('编辑第' + (index + 1) + '行')
    },
    handleInTop(row) {
      let self = this;
      Server._POST(
        rpConfig.API_URI + "/newscenter.Index/setInTop",
        { item_id: row.a_id, a_top: row.a_top },
        function(response) {
          self.$message.success(response.msg);
          self.getData();
        }
      );
    },
    handleDelete(row) {
      let self = this;
      Server._POST(
        rpConfig.API_URI + "/newscenter.Index/deleteNewsItem",
        { item_id: [row.a_id] },
        function(response) {
          self.$message.success(response.msg);
          self.getData();
        }
      );
    },
    delAll() {
      const self = this,
        length = self.multipleSelection.length;
      let delArr = [];
      for (let i = 0; i < length; i++) {
        delArr.push(self.multipleSelection[i].a_id);
      }
      if (delArr.length == 0) {
        self.$message.info("请选择要删除的记录");
      } else {
        Server._POST(
          rpConfig.API_URI + "/newscenter.Index/deleteNewsItem",
          { item_id: delArr },
          function(response) {
            self.$message.success(response.msg);
            self.getData();
          }
        );
      }

      self.multipleSelection = [];
    },
    handleSelectionChange(val) {
      this.multipleSelection = val;
    }
  }
};
</script>

<style scoped>
/* 数据列表 */
@import url("../../../static/css/activity-list.css");
.item-list-detail div {
  margin-bottom: 10px;
}
</style>